package de.tum.in.eist.im.client;

import com.google.gwt.user.client.rpc.AsyncCallback;

import de.tum.in.eist.im.shared.Message;
import de.tum.in.eist.im.shared.User;

public class TestUser {
	User user;
	EIST_IM parent;
	
	public TestUser(String username, String password, EIST_IM p) {
		user = new User(username, password);
		parent = p;
	}
	
	public void run() {
		login();
	}
	
	
	
	public void login() {
		parent.getProxy().login(user, new AsyncCallback<User>() {
			public void onFailure(Throwable caught) {
			}
			public void onSuccess(User result) {	
			}
		});
	}

	public void sendMessage(String messageText) {
		/*
		final Message m = new Message(System.currentTimeMillis(), messageText,
				user);

		parent.getProxy().sendMessage(m, new AsyncCallback<Void>() {
			public void onFailure(Throwable caught) {
			}
			public void onSuccess(Void result) {
			}
		});
		*/
	}

	public void logout() {
		parent.getProxy().logout(user, new AsyncCallback<Boolean>() {
			public void onFailure(Throwable caught) {
			}
			public void onSuccess(Boolean result) {				
			}
		});
	}
}
